#include "Repeat.h"


namespace logo {
	Repeat::Repeat(int iterations) :
		iterations(iterations)
	{
	}


	Repeat::~Repeat()
	{
	}

	void Repeat::addInstructrion(std::unique_ptr<Instruction> instruction)
	{
		instructions.push_back(instruction);
	}

	void Repeat::doExecute(Interpreter &interpreter) const
	{
		for (int i{ 0 }; i < iterations; ++i)
			for (auto &ptr : instructions)
				ptr->execute(interpreter);
	}
}